package com.jin;

import com.alibaba.fastjson.JSON;
import com.jin.工厂模式.简单工厂模式.违背.AwardReq;
import com.jin.工厂模式.简单工厂模式.违背.AwardRes;
import com.jin.工厂模式.简单工厂模式.违背.PrizeController;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class test_awardToUser {
    public Logger logger = LoggerFactory.getLogger(test_awardToUser.class);
    @Test
    public void test(){
        PrizeController prizeController = new PrizeController();
        System.out.println("\r\n模拟发放优惠券测试\r\n");
        //模拟发放优惠券
        AwardReq req01 = new AwardReq();
        req01.setUid("10001");
        req01.setAwardType(1);
        req01.setAwardNumber("EMG11111213121321312154465");
        req01.setBizId("9876516461895163");
        AwardRes awardRes01 = prizeController.awardToUser(req01);
        logger.info("请求参数：{}", JSON.toJSON(req01));
        logger.info("请求参数：{}", JSON.toJSON(awardRes01));
        System.out.println("\r\n模拟发放实物商品\r\n");
        //模拟实物商品
        AwardReq req02 = new AwardReq();
        req02.setUid("10001");
        req02.setAwardType(2);
        req02.setAwardNumber("489441619813515616");
        req02.setBizId("105151581658165181891");
        Map<String,String> extMap = new HashMap();
        extMap.put("consigneeUserName","谢先生");
        extMap.put("consigneeUserPhone","16548948984");
        extMap.put("consigneeUserAddress","娜美克星球");
        req02.setExtMap(extMap);
        AwardRes awardRes02 = prizeController.awardToUser(req02);
        logger.info("请求参数：{}", JSON.toJSON(req02));
        logger.info("测试结果：{}", JSON.toJSON(awardRes02));
        System.out.println("\r\n第三方兑换卡(爱奇艺)\r\n");
        AwardReq req03 = new AwardReq();
        req03.setUid("10001");
        req03.setAwardType(3);
        req03.setAwardNumber("AQY1xjkUodl8LO975GdfrYUio");

        AwardRes awardRes03 = prizeController.awardToUser(req03);
        logger.info("请求参数：{}", JSON.toJSON(req03));
        logger.info("测试结果：{}", JSON.toJSON(awardRes03));
    }
}
